package com.quanquan.store.repository;

import com.quanquan.store.entity.Notice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @ClassName:NoticeRepository
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/4/1 15:32
 * @Version 1.0
 */
public interface NoticeRepository extends JpaRepository<Notice, String>, JpaSpecificationExecutor<Notice> {

    @Query(value = "select * from oo_notice where status_show = 0 and status_remove = 0 and ?1 between start_time and end_time order by create_time desc limit ?2,?3", nativeQuery = true)
    List<Notice> findByStatus(String today, Integer count, Integer size);

    @Query(value = "select * from oo_notice where status_show = 0 and status_remove = 0 and id = ?1", nativeQuery = true)
    Notice findByNoticeId(String id);

    @Query(value = "select * from oo_notice where status_remove = 0 and id = ?1", nativeQuery = true)
    Notice findByBackNoticeId(String id);
}
